# -*-coding:utf-8 -*- #
# ---------------------------------------------------------------------------
# ProjectName:   selenium_self
# FileName:      simple.py
# Author:       test_liu
# Datetime:     2024/8/15 下午2:14
# Description:
# ---------------------------------------------------------------------------
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
import selenium.webdriver.support.expected_conditions as EC


class SE:
    # ec函数简化
    @staticmethod
    def css_element(driver, str1):
        return WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CSS_SELECTOR, str1)))

    @staticmethod
    def xpath_element(driver, str1):
        return WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, str1)))

    @staticmethod
    def css_elements(driver, str1):
        return WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR, str1)))

    @staticmethod
    def xpath_elements(driver, str1):
        return WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, str1)))

    @staticmethod
    def css_click(driver, str1):
        return WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, str1)))

    @staticmethod
    def xpath_click(driver, str1):
        return WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, str1)))
